#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "los_task.h"
#include "gpio_if.h"
#include "spi_if.h"
#include "esp_err.h"
#include "gpio_types.h"
#include "driver/spi_common.h"
#include "driver/spi_master.h"

#define RFID_RST_GPIO_PIN        GPIO_NUM_27
#define RFID_SPI_MISO_PIN        GPIO_NUM_26
#define RFID_SPI_MOSI_PIN        GPIO_NUM_25
#define RFID_SPI_SCLK_PIN         GPIO_NUM_33
#define RFID_SPI_NSS_PIN         GPIO_NUM_5

void RFID_init(void)
{
     // SPI初始化
    esp_err_t ret;
    spi_bus_config_t spiBusConfig =
    {
        .miso_io_num = RFID_SPI_MISO_PIN,                    // MISO信号线
        .mosi_io_num = RFID_SPI_MOSI_PIN,                    // MOSI信号线
        .sclk_io_num = RFID_SPI_SCLK_PIN,                    // SCLK信号线
        .quadwp_io_num = -1,                                 // WP信号线，专用于QSPI的D2
        .quadhd_io_num = -1,                                 // HD信号线，专用于QSPI的D3
        .max_transfer_sz = 0,                               // 最大传输数据大小
    };

    if(spi_bus_initialize(SPI2_HOST,&spiBusConfig,SPI_DMA_DISABLED)!=ESP_OK)
    {
        printf("spi init failed!\r\n")
    }
    else
    {
         printf("spi init success\r\n");
    }  


    spi_device_handle_t rfid_handle;
    spi_device_interface_config_t device_initer={
        .command_bits=0,
        .address_bits=0,
        .mode=0,
        .spics_io_num=15,
        .clock_speed_hz=1000*1000
    };
    if(spi_bus_add_device(SPI2_HOST,&dev_handle,&dev_handle)!=ESP_OK)  printf("add device success\r\n");

   
}


void RFID_example_task(void)
{


}